<?php if (!defined('BASE')) {die('No direct file access.');}

//********************************
//	File:		html_helper.php
//	Author:		Philip Pryce
//	Date:		22nd July 2008
//	Comments:	A helper designed to make writing views a little easier.
//********************************


// -------
// Generates an "a" tag, with the content of $text, any extra attributes you want can be added in an
// associative array using $attr.
// -------
function anchor ($path, $text, $attr=array()) {
	
	$url = WEBURL . '?' . $path;
	
	$anchor = '<a href="' . $url . '"';
	foreach ($attr as $key => $value) {
		$anchor .= ' ' . $key . '="' . $value . '"';
	}
	$anchor .= '>' . $text . '</a>';
	
	return $anchor;
	
}

// -------
// Generates a "img" tag, if $fullpath is set to true, it wont include the WEBURL in the path.
// any extra attributes you want can be added in an associative array using $attr.
// -------
function img ($path, $fullpath=false, $attr) {
	
	$src = WEBURL . $path;
	
	if ($fullpath) {
		$src = $path;
	}
	
	$img = '<img src="' . $path . '"';
	foreach ($attr as $key => $value) {
		$img .= ' ' . $key . '="' . $value . '"';
	}
	$img .= ' />';
	
	return $img;
}

// -------
// Generates a "link" tag
// -------
function linkTag ($path) {
	
	$href = WEBURL . $path;
	
	$link = '<link href="' . $href . '" type="text/css" rel="stylesheet" />';
	
	return $link;
}

// -------
// Generates a "script" tag, if $fullpath is set to true, it wont include the WEBURL in the path.
// -------
function script ($path, $fullpath=false) {
	
	$src = WEBURL . $path;
	
	if ($fullpath) {
		$src = $path;
	}
	
	$script = '<script type="text/javascript" language="javascript" src="' . $src . '"></script>';
	
	return $script;
	
}


?>